<%@ page language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="model.*"%>
<%@ page import="dal.*, util.*"%>
<%@ page import="java.sql.*, java.util.*"%>

<%-- <% --%>
<!-- 	GenericDal<CompanyModel, CompanyModelExt> dal = new GenericDal<CompanyModel, CompanyModelExt> (new CompanyModel()); -->
<!-- 	CompanyModelExt query = new CompanyModelExt(); -->
<!-- 	int iCount = dal.count(query); -->
	
<!-- //	query.setT(0); -->
<!-- 	query.setOffset(3); -->
<!-- 	List<CompanyModel> list = dal.selectList(query); -->

<!-- %> -->


<html>
<head>
<meta http-equiv="Content-Type" content=<%=CommonConstants.CONTENT_TYPE%>>
<title>Create New Company</title>
<script language="javascript" type="text/javascript"
	src="js/datepicker.js"></script>
<link rel="stylesheet" href="css/datepicker.css" />
<link rel="stylesheet" href="css/common.css" />
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery-1.6.1.min.js"></script>

<script language="javascript" type="text/javascript">
	var requiredInputs = [['abb_name','abb_name_required'],['short_name','short_name_required'],['full_name','full_name_required'],['foreign_name','foreign_name_required'],['address','address_required'],['mobile','mobile_required'],['tax_code','tax_code_required'],['description','description_required'],['status','status_required'],['notification','notification_required']];
	var intInputs = [['status','status_invalid'],['notification','notification_invalid']];
	var doubleInputs = [];
	var dateInputs = [];
	var timeInputs = [];

	function checkInputs() {
		var valid = true;

		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
		if (checkIntInputs(intInputs) == false) {
			valid = false;
		}
		if (checkDoubleInputs(doubleInputs) == false) {
			valid = false;
		}
		if (checkDateInputs(dateInputs) == false) {
			valid = false;
		}
		if (checkTimeInputs(timeInputs) == false) {
			valid = false;
		}

		// SPECIFIC VALIDATE CODE HERE		

		return valid;
	}
	
</script>
</head>
<body>
	<form action="CompanyServlet?mode=insert" method="post"
        onSubmit="return checkInputs()"
        onreset="return confirm('Do you really want to reset the form?')">
		<table class="tblInput" border="1">
			<tr class="inputHeader">
				<td colspan="3" class="inputHeader">Create New Company</td>
			</tr>
			<tr class="trField">
				<td class="tdFieldName">Is Competitor</td><td class="tdFieldInput">
					<table class="tblBool">
						<tr class="trBoolSet">
							<td colspan="2" class="tdBoolSet"><input type="checkbox"
								id="ckb_is_competitor" name="ckb_is_competitor"
								onchange="toggleControls(['is_competitor_true', 'is_competitor_false'])" />Not
								set</td>
						</tr>
						<tr class="trBool">
							<td class="tdBool"><input type="radio"
								id="is_competitor_true" name="is_competitor" value="1"
								checked="checked" />Yes</td>
							<td class="tdBool"><input type="radio"
								id="is_competitor_false" name="is_competitor" value="0" />No</td>
						</tr>
					</table></td>
				<td class="tdErrMsg"></td></tr>
			<tr class="trField">
				<td class="tdFieldName">Abb Name</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="abb_name" name="abb_name" maxlength="10" />
				</td>
				<td class="tdErrMsg">
					<span id="abb_name_required" class="errMsg" style="display: none;">Abb Name is required</span>
					<span id="abb_name_invalid" class="errMsg" style="display: none;">Abb Name is invalid</span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Short Name</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="short_name" name="short_name" maxlength="25" />
				</td>
				<td class="tdErrMsg">
					<span id="abb_name_required" class="errMsg" style="display: none;">Short Name is required</span>
					<span id="abb_name_invalid" class="errMsg" style="display: none;">Short Name is invalid</span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Full Name</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="full_name" name="full_name" maxlength="255" />
				</td>
				<td class="tdErrMsg">
					<span id="abb_name_required" class="errMsg" style="display: none;">Full Name is required</span>
					<span id="abb_name_invalid" class="errMsg" style="display: none;">Full Name is invalid</span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Foreign Name</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="foreign_name" name="foreign_name" maxlength="255" />
				</td>
				<td class="tdErrMsg">
					<span id="abb_name_required" class="errMsg" style="display: none;">Foreign Name is required</span>
					<span id="abb_name_invalid" class="errMsg" style="display: none;">Foreign Name is invalid</span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Address</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="address" name="address" maxlength="255" />
				</td>
				<td class="tdErrMsg">
					<span id="abb_name_required" class="errMsg" style="display: none;">Address is required</span>
					<span id="abb_name_invalid" class="errMsg" style="display: none;">Address is invalid</span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Mobile</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="mobile" name="mobile" maxlength="20" />
				</td>
				<td class="tdErrMsg">
					<span id="abb_name_required" class="errMsg" style="display: none;">Mobile is required</span>
					<span id="abb_name_invalid" class="errMsg" style="display: none;">Mobile is invalid</span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Tax Code</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="tax_code" name="tax_code" maxlength="25" />
				</td>
				<td class="tdErrMsg">
					<span id="abb_name_required" class="errMsg" style="display: none;">Tax Code is required</span>
					<span id="abb_name_invalid" class="errMsg" style="display: none;">Tax Code is invalid</span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Description</td>				    <td class="tdFieldInput">
					<textarea id="description" name="description" rows="5" class="inputTextarea"></textarea>
				</td>
				<td class="tdErrMsg">
					<span id="description_required" class="errMsg" style="display: none;">Description is required</span>
					<span id="description_invalid" class="errMsg" style="display: none;">Description is invalid</span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Status</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="status" name="status" maxlength="10" />
				</td>
				<td class="tdErrMsg">
					<span id="status_required" class="errMsg" style="display: none;">Status is required</span> 
					<span id="status_invalid" class="errMsg" style="display: none;">Status is invalid</span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Is Draft</td><td class="tdFieldInput">
					<table class="tblBool">
						<tr class="trBoolSet">
							<td colspan="2" class="tdBoolSet"><input type="checkbox"
								id="ckb_is_draft" name="ckb_is_draft"
								onchange="toggleControls(['is_draft_true', 'is_draft_false'])" />Not
								set</td>
						</tr>
						<tr class="trBool">
							<td class="tdBool"><input type="radio"
								id="is_draft_true" name="is_draft" value="1"
								checked="checked" />Yes</td>
							<td class="tdBool"><input type="radio"
								id="is_draft_false" name="is_draft" value="0" />No</td>
						</tr>
					</table></td>
				<td class="tdErrMsg"></td></tr>
			<tr class="trField">
				<td class="tdFieldName">Notification</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="notification" name="notification" maxlength="10" />
				</td>
				<td class="tdErrMsg">
					<span id="notification_required" class="errMsg" style="display: none;">Notification is required</span> 
					<span id="notification_invalid" class="errMsg" style="display: none;">Notification is invalid</span>
                </td></tr>
			
			<tr class="trInputBottom">
				<td class="trInputBottom" colspan="3">
					<table class="tblSubmit" align="center">
						<tr class="trSubmit">
							<td class="tdSubmit"><input type="submit" value="Submit" />
							</td>
							<td class="tdReset"><input type="reset" value="Reset" /></td>
						</tr>
					</table></td>
			</tr>
		</table>
	</form>
	
<!-- 	<table> -->
<!-- 		<tr> -->
<!-- 			<td> -->
				
<!-- 			</td> -->
<!-- 		</tr> -->
<!-- 	</table> -->
<!-- 	<table class="tblList"> -->
<!-- 		<tr class="tblListHeader"> -->
<!-- 			<td></td> -->
<!-- 			<td>Id</td> -->
<!-- 			<td>Name</td> -->
<!-- 			<td>Code</td> -->
<!-- 			<td>Code</td> -->
<!-- 			<td>Code</td> -->
<!-- 			<td>Code</td> -->
<!-- 			<td>Code</td> -->
<!-- 			<td>Code</td> -->
<!-- 			<td>Code</td> -->
<!-- 			<td>Code</td> -->
<!-- 		</tr> -->

<%-- 		<% --%>
<!-- 			for (int i = 1; i < list.size(); i++) { -->
<!-- 				CompanyModel obj = list.get(i); -->
<!-- 		%> -->
<!-- 		<tr class="trListItem"> -->
<!-- 			<td class="tdListItem"></td> -->
<%-- 			<td class="tdListInt"><%=obj.getId()%></td> --%>
<%-- 			<td class="tdListText"><%=obj.getAbbName()%></td> --%>
<%-- 			<td class="tdListDateTime"><%=obj.getAddress()%></td> --%>
<%-- 			<td class="tdListInt"><%=obj.getCreated()%></td> --%>
<%-- 			<td class="tdListText"><%=obj.getDescription()%></td> --%>
<%-- 			<td class="tdListDateTime"><%=obj.getForeignName()%></td> --%>
<%-- 			<td class="tdListInt"><%=obj.getId()%></td> --%>
<%-- 			<td class="tdListText"><%=obj.getAbbName()%></td> --%>
<%-- 			<td class="tdListDateTime"><%=obj.getAddress()%></td> --%>
<!-- 		</tr> -->
<%-- 		<% --%>
<!-- 			} -->
<!-- 		%> -->
<!-- 	</table> -->
</body>
</html>